package com.jy.adscm.operation.aftersales.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.jy.adscm.bean.system.JyUser;
import com.jy.adscm.exception.AdscmSystemException;
import com.jy.adscm.operation.aftersales.bean.ShSelfRepair;
import com.jy.adscm.operation.aftersales.mapper.mysql.ShSelfRepairMapper;
import com.jy.adscm.operation.aftersales.service.ShSelfRepairService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.jy.adscm.system.mapper.mysql.JyUserMapper;
import com.jy.adscm.utils.AdscmBaseUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zyl
 * @since 2019-07-04
 */
@Service
public class ShSelfRepairServiceImpl extends ServiceImpl<ShSelfRepairMapper, ShSelfRepair> implements ShSelfRepairService {
     @Autowired
    JyUserMapper jyUserMapper;
    @Override
    public List<ShSelfRepair> selectByPid(Integer pid) throws AdscmSystemException {
        Wrapper<ShSelfRepair> wrapper =new EntityWrapper<>();
        wrapper.eq("pid",pid);
        List<ShSelfRepair> shSelfRepairs = super.selectList(wrapper);
        for (ShSelfRepair shSelfRepair : shSelfRepairs) {
            if (AdscmBaseUtils.getInstance().isNotEmpty(shSelfRepair.getCreator(),null)){
                JyUser jyUser = jyUserMapper.selectById(shSelfRepair.getCreator());
                shSelfRepair.setCreatorName(jyUser.getName());
            }
        }
        return shSelfRepairs;
    }
}
